package com.example.constellation.Activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.example.constellation.Adapter.fg1conadapter;
import com.example.constellation.R;
import com.example.constellation.bean.StarBean;
import com.example.constellation.bean.Starfg1bean;
import com.example.constellation.utils.AssetsUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import de.hdodenhof.circleimageview.CircleImageView;

public class fg1listActivity extends AppCompatActivity {
    private TextView title;
    private ImageView title_back;
    private CircleImageView star_iv;
    private TextView startxt,startime;
    private ListView starlist;
    private TextView footinfo;//listview底部布局
    private StarBean.StarinfoBean bean;
    private Map<String, Bitmap> contentlogomap;
    private List<Starfg1bean> mdatas;
    private fg1conadapter fg1conadapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fg1list);
        Intent intent = getIntent();
        bean= (StarBean.StarinfoBean) intent.getSerializableExtra("star");
        init();
        mdatas=new ArrayList<>();
        fg1conadapter = new fg1conadapter(this, mdatas);
        starlist.setAdapter(fg1conadapter);
        addDatattolist();
    }
//加载listview中的数据源
    private void addDatattolist() {
        Starfg1bean sfg1b1 = new Starfg1bean("性格特点：", bean.getTd(), R.color.lightblue);
        Starfg1bean sfg1b2 = new Starfg1bean("掌柜宫位：", bean.getGw(), R.color.lightpink);
        Starfg1bean sfg1b3 = new Starfg1bean("显阴阳性：", bean.getYy(), R.color.lightgreen);
        Starfg1bean sfg1b4 = new Starfg1bean("最大特征：", bean.getTz(), R.color.purple);
        Starfg1bean sfg1b5 = new Starfg1bean("主管星球：", bean.getZg(), R.color.orange);
        Starfg1bean sfg1b6 = new Starfg1bean("幸运颜色：", bean.getYs(), R.color.colorAccent);
        Starfg1bean sfg1b7 = new Starfg1bean("搭配珠宝：", bean.getZb(), R.color.colorPrimary);
        Starfg1bean sfg1b8 = new Starfg1bean("幸运号码：", bean.getHm(), R.color.grey);
        Starfg1bean sfg1b9 = new Starfg1bean("相配金属：", bean.getJs(), R.color.darkblue);
        mdatas.add(sfg1b1);
        mdatas.add(sfg1b2);
        mdatas.add(sfg1b3);
        mdatas.add(sfg1b4);
        mdatas.add(sfg1b5);
        mdatas.add(sfg1b6);
        mdatas.add(sfg1b7);
        mdatas.add(sfg1b8);
        mdatas.add(sfg1b9);
        //数据源发生变化 提示适配器更新
        fg1conadapter.notifyDataSetChanged();
    }

    private void init() {
        title=findViewById(R.id.title);
        title_back=findViewById(R.id.title_back);
        star_iv=findViewById(R.id.star_iv);
        startxt=findViewById(R.id.startxt);
        startime=findViewById(R.id.startime);
        starlist=findViewById(R.id.starlist);
        title.setText("星座详情");
        title_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        startxt.setText(bean.getName());
        startime.setText(bean.getDate());
        contentlogomap = AssetsUtils.getContentlogomap();
        Bitmap bitmap = contentlogomap.get(bean.getLogoname());
        star_iv.setImageBitmap(bitmap);
        //listview添加底部布局
        View footview = LayoutInflater.from(this).inflate(R.layout.fg1foot, null);
        starlist.addFooterView(footview);
        footinfo=footview.findViewById(R.id.footinfo);
        footinfo.setText(bean.getInfo());
    }
}
